<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.List"%>
<%@ page import="lzit.entity.Shanghus"%>
<%@ page import="lzit.ShanghusDao"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>显示商户信息</title>
</head>
<body>
<form action="" method="post">
<table width="90%" border="0" align="center">
<tr>
<td align="right">ID:</td>
<td><input type="text" name="id"></td>
<td align="right">区域：</td>
<td><input type="text" name="qy"></td>
<td align="right"><input type="radio" name="px" value="asc"
checked>ID升序</td>
<td><input type="radio" name="px" value="desc">ID降序
<br></td>
<td><input name="" type="submit" value="提交"></td>
</tr>
</table>
</form>
<%
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
String sid = request.getParameter("id");
String qy = request.getParameter("qy");
String px = request.getParameter("px");
String condition = "";
if (sid!= null &&!sid.equals(""))
condition = " where id=" + sid;
if (qy!= null &&!qy.equals("")) {
condition = (condition.equals(""))? " where  sh_quyu like '%" + qy +
"%'"
: condition + " and sh_quyu='" + qy + "'";
}
if (px!= null)
condition = condition + "  order by id " + px;
String sql = "select * from SHANGHUS " + condition;
ShanghusDao dao = new ShanghusDao();
List<Shanghus> shanghuslist = dao.findAllSh(sql);
if (shanghuslist.size() <= 0) {
out.println("没有满足条件的记录 ");
} else {
%>
<table width="90%" border="0">
<tr>
<td align="center">商户列表</td>
</tr>
<tr>
<td align="center">
<table width="100%" border="1">
<tr align="center">
<th scope="col">编号</th>
<th scope="col">商户名称</th>
<th scope="col">地区</th>
<th scope="col">联系人</th>
<th scope="col">电话</th>
<th scope="col">操作</th>
</tr>
<%
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
for (int i = 0; i < shanghuslist.size(); i++) {
Shanghus m = shanghuslist.get(i);
%>
<tr align="center">
<td><%=m.getId()%></td>
<td><%=m.getSh_name()%></td>
<td><%=m.getSh_quyu()%></td>
<td><%=m.getSh_lianxiren()%></td>
<td><%=m.getSh_dianhua()%></td>
<td>
<a href="editShanghu.jsp?id=<%=m.getId()%>">更新</a>
<a href="deleteShanghu.jsp?id=<%=m.getId()%>">删除</a></td>
</tr>
<%
}
%>
</table>
</td>
</tr>
<tr>
<td colspan="6" align="center"><p>
<a href="addShanghu.jsp">添加</a>
</p></td>
</tr>
</table>
<%
}
%>
</body>
</html>
